﻿
namespace ZquenceStudio3Host.DspPlugins.Synthesizers.Nodesizer.Engine.Modules.LowLevel.Midi
{
    [ModuleDisplay("Midi Add 2")]
    class MidiAddModule : BaseModule
    {
        public readonly ModuleInput A;
        public readonly ModuleInput B;
        public readonly ModuleOutput Out;

        public MidiAddModule(ModuleManager manager)
            : base(manager)
        {
            // Add input and outputs to module.
            AddInput(A = new ModuleInput("A", IOType.Midi, this));
            AddInput(B = new ModuleInput("B", IOType.Midi, this));
            AddOutput(Out = new ModuleOutput("Out", IOType.Midi, this));
        }

        public override void Process()
        {
            // First check if both inputs sources is connected.
            if (A.IsConnected)
            {
                Out.AddMidiMessage(A.FromOutput.MidiBuffer);
            }
            if (B.IsConnected)
            {
                Out.AddMidiMessage(B.FromOutput.MidiBuffer);
            }
        }
    }
}
